[ Mega Script Archive ] [ Readme's ] [ Random Text ]


Copyright and Header


##############################################################################
# Random Text                   Version 1.0                                  #
# Copyright 1996 Matt Wright    mattw@worldwidemart.com                      #
# Created 7/13/96               Last Modified 7/13/96                        #
# Scripts Archive at:           http://www.worldwidemart.com/scripts/        #
##############################################################################
# If you run into any problems while trying to configure this scripts, help  #
# is available.  The steps you should take to get the fastest results, are:  #
#       1) Read this file thoroughly                                         #
#       2) Consult the Matt's Script Archive Frequently Asked Questions:     #
#               http://www.worldwidemart.com/scripts/faq/                    #
#       3) If you are still having difficulty installing this script, send   #
#          e-mail to: scripts-help@tahoenet.com                              #
#          Include any error messages you are receiving and as much detail   # 
#          as you can so we can spot your problem.  Also include the variable#
#          configuration block that is located at the top of the script.     #
#                                                                            #
# Hopefully we will be able to help you solve your problems.  Thank you.     #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
#                                                                            #
# Random Text may be used and modified free of charge by anyone so long as   #
# this copyright notice and the comments above remain intact.  By using this #
# code you agree to indemnify Matthew M. Wright from any liability that      #  
# might arise from it's use.                                                 #  
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium.  In all cases copyright and header must remain intact #
##############################################################################

Overview

  • Random Text is a program which takes a plain text file, which contains a series of phrases, quotes, lines of text, etc... and a delimiter (the character(s) which separate each entry) and will randomly choose one of the phrases and display it on your web page. This requires the use of Server Side Includes, which you can read more about at the FAQ URL listed above.

    There are two files included with this script:

    • README - This file; includes detailed installation instructions.
    • rand_text.pl - The Perl script which generates the random phrase and displays it on your web page.


    The rand_text.pl file has two variables which must be modified. You then must place this file in a special executable directory (usually called cgi-bin) or rename it to end with a .cgi extension if your server is set up that way.


rand_text.pl

  • There are two variables in this program which must be modified:
    $random_file = "/path/to/random.txt";
    This variable points to the location of the file which contains the phrases which you wish to have randomly displayed. This shoul dbe a system path and not a URL.
    $delimiter = "\n\%\%\n";
    This specifies what separates each record. If you leave it as the default, your $random_file database should look like:
          Phrase one would go here.
                As much white space or formatting as you want.
          %%
          Second Phrase would go here.
          %%
          And the next
             Second line of the next.
          %%
          Etc...

    If you set $delimiter = "\n";, then the script would assume that every line is a separate phrase and randomize the file based on that.


How to Implement This In Your Web Pages

  • This script must be called as a Server Side Include, or it can also be called on a page by itself (however that is not as nice looking.) Below are some examples of how to call this program:
        <!--#exec cgi="/url/path/to/rand_text.cgi"-->

    That woudl simply call the program from a Server Side Include and the Random Text woud appear in that location on your web page.


History

      Version 1.0  - 7/13/95       - First Version Released

[ Mega Script Archive ]